package com.lightboat.web.controller.crm;

import cn.hutool.core.util.ObjUtil;
import com.lightboat.common.annotation.Log;
import com.lightboat.common.core.controller.BaseController;
import com.lightboat.common.core.domain.AjaxResult;
import com.lightboat.common.core.page.TableDataInfo;
import com.lightboat.common.enums.BusinessType;
import com.lightboat.common.exception.ServiceException;
import com.lightboat.system.domain.CrmLogisticsTrack;
import com.lightboat.system.service.ICrmLogisticsTrackService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 物流轨迹日志Controller
 *
 * @author lightboat
 * @date 2025-08-30
 */
@Tag(name = "物流轨迹日志")
@RestController
@RequiredArgsConstructor
@RequestMapping("/system/logistics/track")
public class CrmLogisticsTrackController extends BaseController {

    private final ICrmLogisticsTrackService crmLogisticsTrackService;

    /**
     * 查询物流轨迹日志列表
     */
    @Operation(summary = "查询物流轨迹日志列表")
    @PreAuthorize("@ss.hasPermi('system:logistics:track:list')")
    @GetMapping("/list")
    public TableDataInfo list(CrmLogisticsTrack crmLogisticsTrack) {
        if (ObjUtil.isEmpty(crmLogisticsTrack.getWaybillNo())) {
            throw new ServiceException("请输入物流单号");
        }
        List<CrmLogisticsTrack> list = crmLogisticsTrackService.selectCrmLogisticsTrackList(crmLogisticsTrack);
        return getDataTable(list);
    }

    /**
     * 删除物流轨迹日志
     */
    @Operation(summary = "删除物流轨迹日志")
    @PreAuthorize("@ss.hasPermi('system:logistics:track:remove')")
    @Log(title = "物流轨迹日志", businessType = BusinessType.DELETE)
    @DeleteMapping("/{trackIds}")
    public AjaxResult remove(@PathVariable Long[] trackIds) {
        return toAjax(crmLogisticsTrackService.deleteCrmLogisticsTrackByTrackIds(trackIds));
    }
}
